<?php
// set the output content type as text/json
header('Content-Type: text/json');

// load configuration file
require_once('config.php');


$con = mysql_connect("localhost","root","");
if (!$con)
{
    die('Could not connect: ' . mysql_error());
}

mysql_select_db("boekenkast", $con);

$result = mysql_query("SELECT * FROM boek");


$boeken = array();
$i = 0;
while ($row = mysql_fetch_array($result)) 
{
//    echo $row['titel'] . "<br/>";
    $boeken[$i] = array("titel" => $row['titel'], "auteur" => $row['auteur']); 
    $i++;
}

mysql_close($con);

$response = array(
    "boekenkast" => array(
        "boeken" => array(
          "boek" => $boeken
            )));

// json-encode the array
echo json_encode($response);

?>